package com.scau402.system1.domain.po;

import com.baomidou.mybatisplus.annotation.TableName;
import com.scau402.system1.domain.vo.WmsAdjustJadeDetailVO;
import com.scau402.system1.utils.IdGenerator;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;

/**
 * 库存调整单详情
 * @since 2024/2/1
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("wms_adjustbound_order_detail")
public class WmsAdjustBoundOrderDetailPO {
    /**
     * 主键
     */
    private Long id;
    /**
     * 调整单主表id
     */
    private Long adjustOrderId;
    /**
     * 审核单id
     */
    private Long auditId;
    /**
     * 翡翠条码
     */
    private String barcode;
    /**
     * 成本价
     */
    private BigDecimal costPrice;
    /**
     * 标签价
     */
    private BigDecimal tagPrice;
    /**
     * 市场价
     */
    private BigDecimal marketPrice;
    /**
     * 货品名称
     */
    private String jadeName;
    /**
     * 仓库id
     */
    private Long warehouseId;
    /**
     * 仓位id
     */
    private Long storageId;
    /**
     * 原库存数
     */
    private Long oriNum;
    /**
     * 修改后库存数
     */
    private Long newNum;
    /**
     * 供应商id
     */
    private Long supplierId;
    /**
     * 翡翠图片id
     */
    // TODO: 数据库新增该字段
    private Long imageId;

    /**
     * 构建库存调整单详情方法
     * @param idGenerator 自定义id生成器
     * @param orderId 调整单id
     * @param jade 翡翠相关数据
     */
    public void build(IdGenerator idGenerator, Long orderId, WmsAdjustJadeDetailVO jade) {
        this.id = idGenerator.nextId("adjustDetail");
        this.adjustOrderId = orderId;
        this.barcode = jade.getBarcode();
        this.costPrice = jade.getCostPrice();
        this.tagPrice = jade.getTagPrice();
        this.marketPrice = jade.getMarketPrice();
        this.jadeName = jade.getName();
        this.warehouseId = jade.getWarehouseId();
        this.storageId = jade.getStorageId();
        this.oriNum = jade.getOriNum();
        this.newNum = jade.getNewNum();
        this.imageId = jade.getImageId();
        // TODO: 设置供应商id
    }
}
